/*
 * PCtimer.cpp
 *
 *  Created on: 24.11.2012
 *      Author: Vadim
 */
#include "BuildConfig.h"
#include "Global_types.h"
#include "Condition.h"
#include <ctime>
#include <time.h>


#include <process.h>

#include "Task.h"
#include "TimeManager.h"
#include "PCtimer.h"
#include "unistd.h"
using namespace std;

VOID CALLBACK timerCallback(HWND hwnd, UINT uMsg, UINT_PTR idEvent,
		DWORD dwTime) {
	TimeManager::UpdateSystemTime();
#ifdef TIMER_EVENTS_LOGGING
	Log( "Timer called!");
#endif // TIMER_EVENTS_LOGGING
}

void TimerThreadCallback(void *args) {
//	SetTimer(NULL, 0, 1, timerCallback);
//	MSG msg;
	while (*(uint8_t*) args != TRUE) {
//		GetMessage(&msg, NULL, 0, 0);
//		TranslateMessage(&msg);
//		DispatchMessage(&msg);
//		uint64_t tmpTime;
//		if(clock()!=tmpTime)
//		{
//			tmpTime=clock();
//			TimeManager::UpdateSystemTime();
//		}
		for(uint64_t i=0;i<0x3ffff; i++)
		{

		}
		usleep(1000);
		TimeManager::UpdateSystemTime();


		#ifdef TIMER_EVENTS_LOGGING
			Log( "Timer called!");
		#endif // TIMER_EVENTS_LOGGING
	}
	_endthread();
}
